package com.shxy.entity.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.shxy.util.converter.AbstractEnumConverter;
import com.shxy.util.converter.IEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.lang.Nullable;

/**
 * 政治面貌枚举
 */
@Getter
@AllArgsConstructor
public enum PoliticalEnum implements IEnum<String> {
    ZGDY("01", "中共党员"),
    ZGYBDY("02","中共预备党员"),
    GQTU("03","共青团员"),
    MGDY("04","革党员"),
    MMMY("05","民盟盟员"),
    MJIANHY("06","民建会员"),
    MJINHY("07","民进会员"),
    NGDDY("08","农工党党员"),
    ZGDDY("09","致公党党员"),
    JSXSSY("10","九三学社社员"),
    TMMY("11","台盟盟员"),
    WDPRS("12","无党派人士"),
    QZ("13","群众")
    ;
    private String code;
    private String name;

    /**
     * 类型转换器
     */
    public static class Converter extends AbstractEnumConverter<PoliticalEnum, String> {
        public Converter() {
            super(PoliticalEnum.class);
        }
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    @Nullable
    public static PoliticalEnum resolve(String name) {
        for(PoliticalEnum politicalEnum: PoliticalEnum.values()) {
            if(name.equals(politicalEnum.getName())){
                return politicalEnum;
            }
        }
        return null;
    }
}
